<?php	
	session_start(); //begin session to access global data

	class testHome extends PHPUnit_Framework_TestCase {

		public function testHomeFunctionality() {
			//constraints:
			require_once '../database/sql.php'; //info to connect to mysql
			require_once '../modules/customer.php'; //contains customer class


/*******************************Second Perspective******************************/
			if($_POST) {

				$this->assertTrue($_POST);
				// process order
                		if($_POST['order']){
                   			foreach($_SESSION['left_side_object'] as $value) 
                      			$_SESSION['customer']->plate($value);

                    			// write contents to file
                    			file_put_contents('../tables/table1',$_SESSION['customer']->output());
                	}
			//terminate session
				if($_POST['logout']) {
                   			unset($_SESSION['customer']);
                   			unset($_SESSION['right_side']);
                   			unset($_SESSION['left_side']);
                   			unset($_SESSION['left_side_item']);
                   			unset($_SESSION['left_side_object']);
                   			unset($_SESSION['bottom_side']);
                   			unset($_SESSION['bottom_side_item']);
                   			unset($_SESSION['customer_plates']);
                   			unset($_SESSION['played']);
		   			unset($_SESSION['customer_data']);
                		}

				//check the session for the object
				if($_SESSION['customer']) {
					$_SESSION['customer']->meal($_POST); //make part of the customer
                        		file_put_contents('../tables/table1',$_SESSION['customer']->output());
					$_SESSION['customer_data'] = array(
						'cost' => $_SESSION['customer']->cost,
						'calories' => $_SESSION['customer']->calories, 
						'drink' => $_SESSION['customer']->drink, 
						'plate' => $_SESSION['customer']->plate
					);

				} //end check

			} //conclude second perspective


/*******************************First Perspective********************************/

			//store global object
			if(!$_SESSION) {
				$customer = new CUSTOMER(1.1); //create customer at table number
				$this->assertNotNull($customer);

				$_SESSION['customer'] = $customer; //store in session
				$this->assertNotNull($_SESSION['customer']);
			} // end global storage

        		// Logout Button
        		echo "<input type=\"submit\" name=\"logout\" value=\"Logout\" class=\"backButton\" />\n"; // End the session

         		// process Game screen
		 	if(!$_SESSION) {
				$this->assertFalse($_SESSION);
        			echo "<button class=\"menuButton\" onclick\"\">Game Screen</button>\n";
	 		}

		}
	}
?>
